﻿@using EcBlog.Extensions
@model IEnumerable<EcBlog.Models.Tag>
          
@{ var years = Model.SelectMany(c => c.Pages).GroupBy(c => c.Published.Year).Select(c => c.Key).OrderByDescending(c=>c).ToList();


  foreach (var year in years)
  {
      var months = Model.SelectMany(c => c.Pages).Where(c => c.Published.Year == year).GroupBy(c => c.Published.Month).Select(c => c.Key).OrderByDescending(c=>c).ToList();
      foreach (var month in months)
      {
   <p></p>
   <div><h1><a href="@Url.GetArchiveUrl(year, month)">[ @year / @month]</a></h1></div>
   <hr/>
          var posts = Model.SelectMany(c => c.Pages).Where(c => c.Published.Year == year && c.Published.Month == month).Distinct().ToList();
          foreach (var page in posts)
          {
    <div><a href="@Url.GetSlugUrl(page.Published, page.Slug)">@page.Title</a> [ @foreach (var tag in page.Tags)
                                                                            { <a href="@Url.GetTagSlugUrl(tag.TagSlug)">@tag.TagName</a> } ] </div>    
          }
      }
  }
}